<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
   <title>控制系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container" ng-app="myApp" ng-controller="customersCtrl" ng-cloak>
    <div class="layuimini-main">
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>
<script src="../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../js/lay-config.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'table','http'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            http  = layui.http,
            apiurl =http.api;
        init();
        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            init(data.field);
            return false;
        });
        
        function init(resulti){
            http.verifyToken();
            table.render({
                elem: '#currentTableId',
                url: apiurl+'Personal/logsList',
                toolbar: '#toolbarDemo',
                defaultToolbar: ['filter', 'exports', 'print', {
                    title: '提示',
                    layEvent: 'LAYTABLE_TIPS',
                    icon: 'layui-icon-tips'
                }],
                cols: [[
                    // {type: "checkbox", width: 50},
                    {field: 'name', title: '名称'},
                    {field: 'url', title: '地址'},
                    {field: 'parameter',width:'30%', title: '参数'},
                    {field: 'returns', width:'30%',title: '返回值'},
                    {field: 'create_time', title: '创建时间'},
                ]],
                where: resulti,
                headers: { //通过 request 头传递
                    Authorization:  layui.data(http.token)['token']
                },
                limits: [10, 15, 20, 25, 50, 100],
                limit: 15,
                page: true,
                skin: 'line'
            });
        }

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            var id = obj.data.id;
            if (obj.event === 'delete') {
                layer.confirm('真的删除么', function (index) {
                    http.httpajax("Personal/userlevelAccessDel",{'id':id},"POST",function(res) {
                        layer.msg(res.msg);
                        if(res.code === '0000'){
                            obj.del();
                            init();
                        }
                    });
                });
            }
        });

    });
</script>

</body>
</html>